<?php defined('_JEXEC') or die('Restricted access'); ?>

<?php JHTML::_('behavior.tooltip'); ?>

<?php
	$cid = JRequest::getVar( 'cid', array(0) );
	$edit = JRequest::getVar('edit',true);
	$text = intval($edit) ? JText::_( 'Edit' ) : JText::_( 'New' );

	$delete = $this->producent->del;

	$text = $delete ? 'Usunięty' : $text;
	JToolBarHelper::title( 'Producent' . ': <small><small>[ '. $text .' ]</small></small>' , 'producent.png' );
	JToolBarHelper::pdf();

	global $form_edit;
	// Zablokowanie edycji "archiwalnych" dla administratora
	$form_edit = ( $form_edit == true && $delete == 0 );
	
	if ( $form_edit ) {
		JToolBarHelper::save();
		JToolBarHelper::cancel();
	} else  { 
		JToolBarHelper::back2();
	}

	//JToolBarHelper::help( 'screen.producenci.edit' );
?>

<?php
	// clean item data
	JFilterOutput::objectHTMLSafe( $this->producent, ENT_QUOTES, '' );
?>
<script language="javascript" type="text/javascript">
	function submitbutton(pressbutton) 
	{
		var form = document.adminForm;
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}

		// do field validation
		if (trim(form.name.value) == "") {
			alert( "Podaj nazwę producenta!" );
		} else {
			submitform( pressbutton );
		}
	}
</script>

<form action="index.php" method="post" name="adminForm" autocomplete="off">
	<div class="col">
		<fieldset class="adminform">
		<legend><?php echo 'Szczegóły producenta'; ?></legend>
			<table class="admintable" cellspacing="1">
				<tr>
					<td width="150" class="key">
						<label for="name">
							Nazwa producenta
						</label>
					</td>
					<td>
					<!-- NIE WIEM DLACZEGO TYLKO W TYM FORMULARZU NIE YRZEBA WSTAWIĆ FUNKCJI htmlspecialchara() I ZNAKI SPECJALNE SA ODCZYTYWANE PRAWIDŁOWO -->
					<?php if ( $form_edit ) { ?>
					 	 <input type="text" name="name" id="name" class="inputbox" style="width:400px;" value="<?php echo ($this->producent->get('name')); ?>" />
					 <?php      } else {  ?>
					 	 <input type="text" name="name" id="name" class="inputbox" readonly="readonly" style="width:400px;" value="<?php echo ($this->producent->get('name')); ?>" />
					<?php } ?>
					</td>
				<tr>
					<td valign="top" class="key">
						<label for="nota">
							Notatka
						</label>
					</td>
					<td>
					<?php if ( $form_edit ) { ?>
						 <textarea class="text_area" cols="60" rows="2"                     style="width:400px; height:40px" id="nota" name="nota"><?php echo ($this->producent->get('nota')); ?></textarea>
					 <?php      } else {  ?>
					 	 <textarea class="text_area" cols="60" rows="2" readonly="readonly" style="width:400px; height:40px" id="nota" name="nota"><?php echo ($this->producent->get('nota')); ?></textarea>
					<?php } ?>
					</td>
				</tr>
				</tr>
			</table>
		</fieldset>
<?php if ($this->producent->get('id') && $delete) { ?>
	<fieldset class="adminform">
	<legend><?php echo 'Producent został usunięty'; ?></legend>
		<table class="admintable" cellspacing="1">
			<tr>
				<td class="key">
					w dniu
				</td>
				<td>
					<?php echo $this->producent->registerDate; ?>
				</td>
			</tr>			
			<tr>
				<td class="key">
					przez
				</td>
				<td>
					<?php echo $this->producent->whoRegister; ?>
				</td>
			</tr>	
		</table>
	</fieldset>
<?php } ?>
	</div>
	<div class="clr"></div>

	<input type="hidden" name="id" value="<?php echo $this->producent->get('id'); ?>" />
	<input type="hidden" name="cid[]" value="<?php echo $this->producent->get('id'); ?>" />
	<input type="hidden" name="nrp" value="<?php echo $this->producent->get('nrp'); ?>" />
	<input type="hidden" name="option" value="com_producenci" />
	<input type="hidden" name="task" value="" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>
